package net.caidingke.shepherd.utils.result;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author bowen
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
@Getter
public class ResultPage<T> extends Response{

    private static final long serialVersionUID = 6769973984136886424L;
    public List<T> content = new ArrayList<T>();

    public long total;

    public int page = 0;

    public int pageSize = 100;

    public Object extra = null;

    public ResultPage setContent(List<T> content) {
        this.content = content;
        return this;
    }

    ResultPage setTotal(long total) {
        this.total = total;
        return this;
    }

    ResultPage setPage(int page) {
        this.page = page;
        return this;
    }

    ResultPage setPageSize(int pageSize) {
        this.pageSize = pageSize;
        return this;
    }

    public ResultPage setExtra(Object extra) {
        this.extra = extra;
        return this;
    }

    @Override
    public ResultPage setStatus(int status) {
        super.setStatus(status);
        return this;
    }

    @Override
    public ResultPage setMsg(String msg) {
        super.setMsg(msg);
        return this;
    }

    static <T> ResultPage<T> newInstance() {
        return new ResultPage<>();
    }

}
